import request from '@u/request'
const UserModule = 'index'
// 数据汇聚

// 获取任务列表
export function getTaskList(params) {
  return request.get(`${UserModule}/schedule/query.json`, {
    params,
  })
}
// 添加任务
export function addTask(params) {
  return request.post(`${UserModule}/schedule/add.json`, JSON.stringify(params))
}
export function editMap(pkid, params) {
  return request.put(
    `${UserModule}/schedule/manage/update/${pkid}`,
    JSON.stringify(params)
  )
}
// 删除任务
export function delTask(pkid) {
  return request.delete(`${UserModule}/schedule/delete.json`, {
    params: {
      pkid,
    },
  })
}

// 任务填报

// 获取任务详情
export function getTaskDetail(pkid) {
  return request.get(`${UserModule}/schedule/query/task/${pkid}`)
}

// 填报任务

export function fillInTask(id, params) {
  return request.put(
    `${UserModule}/schedule/update/${id}`,
    JSON.stringify(params)
  )
}

// 退回任务填写内容
export function backTask(taskId, depId) {
  return request.put(
    `${UserModule}/schedule/task/rollback/${taskId}?deptId=${depId}`
  )
}

// 数据查询

// 部门视角
export function deptList(params) {
  return request.get(`${UserModule}/schedule/query/dept`, {
    params,
  })
}
export function dataList(params) {
  return request.get(`${UserModule}/schedule/query/data`, { params })
}
export function dataOrDeptDetail(params) {
  return request.get(`${UserModule}/schedule/query/task/data`, { params })
}

// 指标聚合汇总填报进度列表查询
export function queryProgressList(params) {
  return request.get(`${UserModule}/index/pro/quota/agg/query`, { params })
}

// 指标体系下的指标进度列表查询
export function queryProgressInfo(params) {
  return request.get(`${UserModule}/index/pro/quota/query`, { params })
}

// 指标体系下的指标进度总列表导出
export function downloadExcel(params) {
  return request.get(`${UserModule}/index/pro/quota/query/export`, {
    params: params,
    responseType: 'blob',
  })
}

// 指标体系下的指标进度管理填报历史记录
export function queryHisProgressInfo(params) {
  return request.get(`${UserModule}/index/pro/quota/his/query`, { params })
}

// 添加/更新指标填报进度
export function addProgress(params) {
  return request.post(`${UserModule}/index/pro/add`, JSON.stringify(params))
}

export const uploadUrl = `${window.BASE_URL}/${UserModule}/index/upload/file`
